{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Node():\n",
    "    def __init__(self,value):\n",
    "        self.value = value\n",
    "        \n",
    "class Nodes(list):\n",
    "        def __contains__(self,node):\n",
    "            for s in self:\n",
    "                if s.value == node.value:\n",
    "                    return True\n",
    "            return False        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "n1 = Node('linear')\n",
    "n2 = Node('sigmoid')\n",
    "a = Nodes()\n",
    "a.extend([n1,n2])\n",
    "n3 = Node('linear')\n",
    "print(n3 in a) # True\n",
    "n4 = Node('tanh')\n",
    "print(n4 in a) # False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'value': 'linear'}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n1.__dict__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'value': 'linear'}\n",
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "class Node():\n",
    "    def __init__(self,value):\n",
    "        self.value = value\n",
    "    def __eq__(self,node):\n",
    "        return self.__dict__ == node.__dict__\n",
    "    \n",
    "n1 = Node('linear')\n",
    "n2 = Node('sigmoid')\n",
    "n3 = Node('linear')\n",
    "\n",
    "print(n1.__dict__) # {'value': 'linear'}\n",
    "print(n1 == n2) # False\n",
    "print(n1 == n3) # True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
